#ifndef WIDGET_H
#define WIDGET_H

#include "ui_rollcall.h"
#include "widgetShow.h"
#include <QWidget>
#include <QPushButton>
#include <QLabel>
#include <QGridLayout>
#include <QTimer>
#include <QRandomGenerator>
#include <QFileDialog>
#include <QTextStream>
#include <QMessageBox>
#include <QTime>
#include <QDebug>
#include <QRegularExpression>
#include "nameCaller.h"
#include <QStandardPaths>
#include <QThread>
#include <QMimeData>
#include <QDragEnterEvent>
#include <QListData>
#include <QList>
#include <QDropEvent>

QT_BEGIN_NAMESPACE
namespace Ui { class RollCall; }
QT_END_NAMESPACE
class RollCall : public QWidget
{
    Q_OBJECT

public:
    RollCall(QWidget *parent = 0);
    ~RollCall();
private:
    /*------------------随机点名部分-----------------*/
    nameCaller *nameCallerObj;
    bool callerImported = false;
    bool nameCalling = false;
    QThread callerThread;  // 接收线程

    /*------------------默认显示文本-----------------*/
    const QString nameLabelDefault = QString("请导入文件");
    const QString startButtonDefault = QString("开始点名");
    const QString stopButtonDefault = QString("停！");
    const QString nameLabelNull = QString("姓名");

    const QString filePathLabelDefault = QString("未选择");

    const QString fileFilter = "纯文本文件(*.txt)";
    QString desktopPath = ".";

    /*------------------其他-----------------*/
    Ui::RollCall *ui;
    void closeEvent(QCloseEvent *event);
    QList<quint32> randNumList;
    bool startButtonFlag = true;
    QRandomGenerator numRandomGen;
    quint32 randNum = 1;
    quint32 minRandNum = 1;
    quint32 maxRandNum = 2;
    quint32 numListSize = 0;
    void numSetCheck();
    RollCallShow *showUI;
    bool showWinOpen = false;


    /*------------------扩展窗口-----------------*/
    void closeShowWin();
    void openShowWin();
private slots:
    /*------------------随机点名部分-----------------*/
    void callerImportResult(bool isError, QString msg = "");
    void callOver();
    void callNameShow(QString name);
    void callBtn();

    /*------------------其他-----------------*/
    void importButtonClicked();
    void genRandNum();
    void clearNumData();
    void ctrlShowWin();
    void showWinClosed();


    /*------------------ui显示-----------------*/
    void setName(QString name);
    void setNum(QString num);

signals:
    /*------------------随机点名部分-----------------*/
    void selectFile(QString filePath);
    void callBtnClicked();
protected:
    void dragEnterEvent(QDragEnterEvent *event);
    void dropEvent(QDropEvent *event);
};

#endif // WIDGET_H
